//调用request.js中的request方法
import request from '@/utils/request.js'

//根据userId和postId获取用户对该帖子的所有互动（点赞和收藏）
export const getLikesIdService = (userId,postId) => {
    return request.get('/lk/getLkId', {
        params: {
            userId,
            postId
        }}
    )
}

// 添加点赞
export const addLikeService = (like) => {
    return request.post('/lk/addLike', like)
}

// 添加收藏
export const addFavoriteService = (favorite) => {
    return request.post('/lk/addFavorite', favorite)
}

// 获取用户点赞列表
export const getUserLikesService = (userId, type) => {
    return request.get('/lk/UserLkList', {
        params: {
            userId: userId,
            type: type
    }})
}

// 获取用户收藏列表
export const getUserFavoritesService = (userId, type) => {
    return request.get('/lk/UserFavorites', {
        params: {
            userId: userId,
            type: type
        }
    })
}

//判断当前用户是否点赞
export const isLikeService = (userId, postId) => {
    return request.get('/lk/isLike', {
        params: {
            userId: userId,
            postId: postId
        }
    })
}

//判断当前用户是否收藏
export const isFavoriteService = (userId, postId) => {
    return request.get('/lk/isFavorite', {
        params: {
            userId: userId,
            postId: postId
        }
    })
}

// 获取点赞，收藏作者
export const getAuthorService = (userId) => {
    return request.get(`/lk/author/${userId}`)
}

//获取帖子点赞总数
export const getPostLikeCountService = (postId) => {
    return request.get(`/lk/likeCount/${postId}`)
}

//获取帖子收藏总数
export const getPostFavoriteCountService = (postId) => {
    return request.get(`/lk/favoriteCount/${postId}`)
}

// 取消点赞
export const removeLikeService = (LkId) => {
    return request.delete(`/lk/like/${LkId}`)
}

// 取消收藏
export const removeFavoriteService = (LkId) => {
    return request.delete(`/lk/favorite/${LkId}`)
}